#ifndef INVOICEDIALOG_H
#define INVOICEDIALOG_H

#include "ui_InvoiceInputDialog.h"
#include <QSortFilterProxyModel>

#include "ProductsModel.h"
#include "Invoice.h"
#include "InvoiceItem.h"
#include "InvoiceItemModel.h"

namespace ecocity
{


class InvoiceDialog : public QDialog, private Ui::InvoiceInputDialog
{
    Q_OBJECT

public:

    InvoiceDialog( const Customer& customer,
                   const std::vector< Product >& products,
                   QWidget* parent = 0 );

    // Get Results from Dialog
    Invoice get_invoice( ) const;
    std::vector< InvoiceItem > get_invoice_items( ) const;

private slots:

    // Se llama cuando se cierra el Dialogo con Accept
    void accept( );

    // Se llama cuando se abre el InvoiceItemDialog
    void on_add_invoice_item( );

    void on_delete_item_clicked();

    void on_export_invoice_clicked();

    void model_changed( );

private:


    void update_summary( );

private:

    Customer m_customer;

    std::vector< Product > m_products;
    Invoice m_invoice;

    InvoiceItemsModel m_invoice_items_model;
};

} // namespace ecociy

#endif // INVOICEDIALOG_H
